fix(tests): isolate state in test_write_optional_list#3334
Open
paultmathew wants to merge 1 commit intoapache:mainfrom
Open
fix(tests): isolate state in test_write_optional_list#3334paultmathew wants to merge 1 commit intoapache:mainfrom
paultmathew wants to merge 1 commit intoapache:mainfrom
Conversation
Fokko
reviewed
May 7, 2026
Contributor
Fokko
left a comment
There was a problem hiding this comment.
Thanks @paultmathew for spotting and fixing this! I left one suggestion, LMKWYT
Comment on lines
+2030
to
+2038
| # Ensure a clean slate: the test asserts exact row counts after each | ||
| # append, so a stale table from a previous run would accumulate rows and | ||
| # fail. Other tests in this module use _create_table() which does the same | ||
| # drop-if-exists step. | ||
| try: | ||
| session_catalog.drop_table(identifier=identifier) | ||
| except NoSuchTableError: | ||
| pass | ||
| session_catalog.create_table(identifier, schema) |
Contributor
There was a problem hiding this comment.
How about re-using the _create_table util:
iceberg-python/tests/integration/test_writes/utils.py
Lines 62 to 81 in d008a04
Author
There was a problem hiding this comment.
Done. Switched to _create_table(). Diff is now a one-liner. Thanks for the cleanup pointer!
`test_write_optional_list` uses `create_table_if_not_exists` and then asserts exact row counts after two `tbl.append()` calls. On any subsequent run the table is reused, so the asserted counts (2, then 4) become 6, 10, ... and the test fails. The failure only surfaces when the integration suite is replayed without a fresh docker-compose stack, which masks the bug in CI but makes it a papercut for local development. Drop the table at the start to guarantee a clean slate, matching the pattern used by `_create_table()` for every other write test in this module.
4ea23bb to
1917b48
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
test_write_optional_listusescreate_table_if_not_existsand then asserts exact row counts (2 after the first append, 4 after the second). The table is reused across runs, so a second invocation against the same docker-compose stack accumulates rows — counts become 6, 10, 14, … and the asserts fail.CI hides this because it spins up a fresh
docker-compose-integrationstack for every job. Locally it bites anyone who runsmake test-integration-exectwice withoutmake test-integration-cleanupin between.Fix: drop the table at the start so the test always starts from a clean slate, matching the
drop-then-createpattern used by_create_table()for every other write test in this module.Are these changes tested?
Yes — verified locally that the test now passes when run twice back-to-back without resetting the docker stack:
Full
tests/integration/test_writes/test_writes.pysuite: 122 passed, 1 skipped.Are there any user-facing changes?
No.
Noticed while preparing the PR for #2152 (
RecordBatchReaderstreaming append).